package com.chinasoft.gen;

import org.apache.ibatis.io.Resources;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class MyGen {

    // c2 on master local
    // c3 on master local

    // c6 on master local
    // c7 on master local
    // c8 on master local

    public static void main(String[] args) throws Exception {

        // c4 on master origin
        // c5 on master origin
        // c9 on master origin
        
        List<String> warnings = new ArrayList<String>();
        boolean overwrite = true;
//        File configFile = new File("generatorConfig.xml");
        // 得到 输入流对象
//        InputStream is = (new MyGen()).getClass().getClassLoader().getResourceAsStream("generatorConfig.xml");
        InputStream is = Resources.getResourceAsStream("generatorConfig.xml");
        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration config = cp.parseConfiguration(is);
        DefaultShellCallback callback = new DefaultShellCallback(overwrite);
        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
        myBatisGenerator.generate(null);
    }
}
